home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Performance tools / 604 Performance / Source Code / 604Performance.s < prev    next >
Encoding:
Text File  |  1995-10-25  |  5.5 KB  |  241 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        604Performance.s
  3. ;
  4. ;    Contains:    604 Performance Code
  5. ;
  6. ;    Written by: dgc = Douglas George Clarke
  7. ;
  8. ;    Copyright:    © 1995 by Apple Computer, Inc., All Rights Reserved.
  9. ;
  10.  
  11.  
  12. ;******************************************************************************************
  13. ;
  14. ; Macro definitions used throughout the file
  15. ;
  16.  
  17. ;
  18. ; Makecsect - Creates a new program section.
  19. ;
  20.  
  21.                     MACRO
  22.                     makecsect    &name
  23.                     
  24.                     function    &name.[pr]
  25.                     csect         &name.[pr]
  26.     
  27.                     ENDM
  28.  
  29. ;
  30. ; Makeexport - Exports the specified name so that other object files can reference it.
  31. ;
  32.                     MACRO
  33.                     makeexport    &name
  34.                 
  35. &name                export        &name
  36.  
  37.                      ENDM
  38.  
  39. ;
  40. ; C_PROLOGUE - Glue code used to set up our environment when we get called from C.
  41. ;
  42.  
  43.                     MACRO
  44.                     C_PROLOGUE &spaceToSave
  45.  
  46.                      mflr    r0                            ;get link register
  47.                     stw        r0,0x0008(SP)                ;store the link resgister on the stack
  48.                     stwu    SP,-&spaceToSave(SP)        ;skip over the stack space where the caller
  49.                                                         ;  might have saved stuff
  50.                     ENDM
  51.         
  52. ;
  53. ; C_EPILOGUE - Glue code used to tear down our environment when we return to C.
  54. ;
  55.  
  56.                     MACRO
  57.                     C_EPILOGUE &spaceToRestore
  58.  
  59.                     lwz        r0, 0x8+&spaceToRestore(SP)    ;get the saved link register
  60.                     addic    SP,SP,&spaceToRestore        ;reset the stack pointer
  61.                     mtlr    r0                            ;reset the link register
  62.                     blr                                    ; return via the link register
  63.  
  64.                     ENDM
  65.  
  66.  
  67. ;******************************************************************************************
  68. ;
  69. ; Table of contents (TOC) entries
  70. ;
  71.  
  72.                     tc        .GetPMC[tc],.GetPMC                
  73.                     tc        .ClearPMC[tc],.ClearPMC                
  74.                     tc        .SetMMCR0[tc],.SetMMCR0                
  75.  
  76.  
  77. ;******************************************************************************************
  78. ;
  79. ; void GetPMC( long *PMC1, long *PMC2)
  80. ;
  81. ; Copy the PMC Registers into the longs pointed at by PMC1 and PMC2
  82. ;
  83.  
  84.                     makecsect    .GetPMC
  85.                     makeexport    .GetPMC
  86.  
  87. ;
  88. ; High memory
  89. ;
  90.  
  91. numFPRs:            set        0        ; num non-volatile FPRs (FPRs 14-31) we use
  92. numGPRs:            set        0        ; num non-volatile GPRs (GPRs 13-31) we use
  93. CalleesLocalVars:     set        0        ; we do not have any
  94. CalleesParams:        set        32        ; always leave space for GPRs 3-10
  95. linkageArea:        set        24        ; constant comes from the PowerPC Runtime Architecture Document
  96.  
  97. ;
  98. ; Low memory
  99. ;
  100.  
  101. saveSpace:            set        linkageArea + CalleesParams + CalleesLocalVars + 4*numGPRs + 8*numFPRs  
  102. gprsBase:            set     linkageArea + CalleesParams + CalleesLocalVars
  103.  
  104.  
  105. basePtr                set        r3
  106. numBytes            set        r4
  107. endPtr                set        r4
  108.                 
  109.                     C_PROLOGUE saveSpace
  110.  
  111. ReadCounters:
  112. ;            mfspr    r5,953
  113. ;            dc.l    %011111 00101 11001 11101 0101010011 0
  114.             dc.l    %01111100101110011110101010100110
  115.             stw        r5,0(r3)
  116. ;            mfspr    r5,954
  117. ;            dc.l    %011111 00101 11010 11101 0101010011 0
  118.             dc.l    %01111100101110101110101010100110
  119.             stw        r5,0(r4)
  120.  
  121.                     C_EPILOGUE saveSpace                ;this tears down the stack and returns via a blr
  122.  
  123. ;******************************************************************************************
  124. ;
  125. ; void ClearPMC( void)
  126. ;
  127. ; Clear the PMC1 Registers
  128. ;
  129.  
  130.                     makecsect    .ClearPMC
  131.                     makeexport    .ClearPMC
  132.  
  133. ;
  134. ; High memory
  135. ;
  136.  
  137. numFPRs:            set        0        ; num non-volatile FPRs (FPRs 14-31) we use
  138. numGPRs:            set        0        ; num non-volatile GPRs (GPRs 13-31) we use
  139. CalleesLocalVars:     set        0        ; we do not have any
  140. CalleesParams:        set        32        ; always leave space for GPRs 3-10
  141. linkageArea:        set        24        ; constant comes from the PowerPC Runtime Architecture Document
  142.  
  143. ;
  144. ; Low memory
  145. ;
  146.  
  147. saveSpace:            set        linkageArea + CalleesParams + CalleesLocalVars + 4*numGPRs + 8*numFPRs  
  148. gprsBase:            set     linkageArea + CalleesParams + CalleesLocalVars
  149.  
  150.                 
  151.                     C_PROLOGUE saveSpace
  152.  
  153. ClearCounters:
  154.             li        r5,0
  155. ;            mtspr    r5,953
  156. ;            dc.l    %011111 00101 11001 11101 0111010011 0
  157.             dc.l    %01111100101110011110101110100110
  158. ;            mtspr    r5,954
  159. ;            dc.l    %011111 00101 11010 11101 0111010011 0
  160.             dc.l    %01111100101110101110101110100110
  161.  
  162.                     C_EPILOGUE saveSpace                ;this tears down the stack and returns via a blr
  163.  
  164. ;******************************************************************************************
  165. ;
  166. ; void SetMMCR0( long    PMC1Select, long PMC2Select, long user, long system)
  167. ;
  168. ; Build the MMCR0 word and store it in the MMCR0
  169. ;
  170.  
  171.                     makecsect    .SetMMCR0
  172.                     makeexport    .SetMMCR0
  173.  
  174. ;
  175. ; High memory
  176. ;
  177.  
  178. numFPRs:            set        0        ; num non-volatile FPRs (FPRs 14-31) we use
  179. numGPRs:            set        0        ; num non-volatile GPRs (GPRs 13-31) we use
  180. CalleesLocalVars:     set        0        ; we do not have any
  181. CalleesParams:        set        32        ; always leave space for GPRs 3-10
  182. linkageArea:        set        24        ; constant comes from the PowerPC Runtime Architecture Document
  183.  
  184. ;
  185. ; Low memory
  186. ;
  187.  
  188. saveSpace:            set        linkageArea + CalleesParams + CalleesLocalVars + 4*numGPRs + 8*numFPRs  
  189. gprsBase:            set     linkageArea + CalleesParams + CalleesLocalVars
  190.  
  191.  
  192. PMC1Select            set        r3
  193. PMC2Select            set        r4
  194.                 
  195.                     C_PROLOGUE saveSpace
  196.  
  197. SetTheMMCRO:
  198.             rotlwi    r7,r3,6
  199.             or        r7,r7,r4
  200.             cmpi    0,0,r5,0
  201.             bne        @1
  202.             addi    r5,r0,$2000
  203.             rotlwi    r5,r5,16
  204.             or        r7,r7,r5
  205. @1            cmpi    0,0,r6,0
  206.             bne        @2
  207.             addi    r5,r0,$4000
  208.             rotlwi    r5,r5,16
  209.             or        r7,r7,r5
  210. @2
  211. ;            mtspr    r5,952
  212. ;            dc.l    %011111 00111 11000 11101 0111010011 0
  213.             dc.l    %01111100111110001110101110100110
  214.  
  215.                     C_EPILOGUE saveSpace                ;this tears down the stack and returns via a blr
  216.  
  217. ;******************************************************************************************
  218. ;
  219. ; TVector for InternalFlushCacheRangePPC
  220. ;
  221.  
  222.                     EXPORT    GetPMC[ds]
  223. GetPMC                csect    GetPMC[ds]
  224.                     dc.l    .GetPMC
  225.                     dc.l    TOC[tc0]
  226.                     dc.l    0
  227.  
  228.                     EXPORT    ClearPMC[ds]
  229. ClearPMC            csect    ClearPMC[ds]
  230.                     dc.l    .ClearPMC
  231.                     dc.l    TOC[tc0]
  232.                     dc.l    0
  233.  
  234.                     EXPORT    SetMMCR0[ds]
  235. SetMMCR0            csect    SetMMCR0[ds]
  236.                     dc.l    .SetMMCR0
  237.                     dc.l    TOC[tc0]
  238.                     dc.l    0
  239.  
  240.                     END
  241.